package org.leaf.green.b2b

class StockOutDetail {

    StockOut stockOut//出库单
    String serialNumber//序号
    DistributionDetail distributionDetail//配送明细
    Product product//产品
    String unit//单位
    BigDecimal quantity//配送数量
    BigDecimal actual//实际出库数量
    BigDecimal price//价格
    BigDecimal amount//金额

    static belongsTo = [stockOut : StockOut]
    static hasMany = [details : StockInOutDetail]

    static constraints = {
        stockOut(nullable : false)
        serialNumber(nullable:false, blank:false, unique : 'stockOut', maxSize : 3)
        distributionDetail(nullable:false)
        product(nullable:false)
        unit(nullable:false, blank:false, maxSize : 4)
        requestQuantity(nullable:false, scale : 2)
        actualQuantity(nullable:false, scale : 2)
        price(nullable:false, scale : 2)
        amount(nullable:false, scale : 2)
    }

    String toString(){
        return "$serialNumber"
    }


    static mapping = {
        table 'B2B_STOCKOUT_DETAIL'
        details cascade:"all-delete-orphan", sort:"serialNumber", batchSize: 100
    }
}
